<?php $this->headLink()->appendStylesheet($this->baseUrl() . '/css/catalog-category.css') ?>
<?php
$urlParams = array(
    'controller' => 'catalog',
    'action' => 'index',
);
$routing = 'default';
if (isset($this->urlParams) && is_array($this->urlParams)) {
    $urlParams = $this->urlParams;
}
if (isset($this->routing)) {
    $routing = $this->routing;
}
$isAddMode = false;
if (isset($this->addMode) && $this->addMode) {
    $isAddMode = true;
}
?>
<div class="row-fluid catalog_categories">
    <?php foreach ($this->categories as $i => $cat): ?>
        <div class="category_box span4">
            <div class="title">
                <a style="background-image: url(<?= $cat['icon_path'] ?>);" href="<?= $this->url(array('controller' => 'catalog', 'action' => 'index', 'id' => $cat['code'], 'name' => $cat['name']), 'default', true) ?>"><?= $cat['name'] ?></a>
            </div>
            <?php if (!empty($cat['categories'])): ?>
                <ul class="subcategories">
                    <?php foreach ($cat['categories'] as $scat): ?>
                        <li>
                            <?php
                            $urlParamsTmp = $urlParams;
                            $urlParamsTmp['id'] = $scat['code'];
                            $urlParamsTmp['name'] = $scat['name'];
                            $urlParamsTmp['supername'] = $cat['name'];
                            ?>
                            <a href="<?= $this->url($urlParamsTmp, $routing, true) ?>"><?= $scat['name'] ?></a>                           
                        </li>
                    <?php endforeach ?>
                </ul>
            <?php endif ?>
        </div>
    <?php endforeach ?>
    <div class="clearfix"></div>
    <div class="new_catalog_link">
        <a href="<?= $this->url(array('controller' => 'catalog', 'action' => 'add'), 'default', true) ?>"><i class="icon-plus"></i>Dodaj nowy wpis</a>
    </div>
</div>
